package com.member.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.member.common.utils.DateUtils;
import com.member.shop.domain.SysBizOrderGoods;
import com.member.shop.mapper.SysBizOrderGoodsMapper;
import com.member.shop.service.ISysBizOrderGoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * 订单商品Service业务层处理
 *
 * @author lixinchen
 * @date 2024-01-08
 */
@Service
public class SysBizOrderGoodsServiceImpl extends ServiceImpl<SysBizOrderGoodsMapper, SysBizOrderGoods> implements ISysBizOrderGoodsService {
    @Resource
    private SysBizOrderGoodsMapper sysBizOrderGoodsMapper;

    /**
     * 查询订单商品
     *
     * @param id 订单商品主键
     * @return 订单商品
     */
    @Override
    public SysBizOrderGoods selectSysBizOrderGoodsById(Long id) {
        return sysBizOrderGoodsMapper.selectById(id);
    }

    /**
     * 查询订单商品列表
     *
     * @param sysBizOrderGoods 订单商品
     * @return 订单商品
     */
    @Override
    public List<SysBizOrderGoods> selectSysBizOrderGoodsList(LambdaQueryWrapper<SysBizOrderGoods> queryWrapper) {
        return sysBizOrderGoodsMapper.selectList(queryWrapper);
    }

    /**
     * 查询订单商品列表
     *
     * @param sysBizOrderGoods 订单商品
     * @return 订单商品
     */
    @Override
    public List<SysBizOrderGoods> selectSysBizOrderGoodsList(SysBizOrderGoods sysBizOrderGoods) {
        return sysBizOrderGoodsMapper.selectSysBizOrderGoodsList(sysBizOrderGoods);
    }

    /**
     * 新增订单商品
     *
     * @param sysBizOrderGoods 订单商品
     * @return 结果
     */
    @Override
    public int insertSysBizOrderGoods(SysBizOrderGoods sysBizOrderGoods) {
        sysBizOrderGoods.setCreateTime(DateUtils.getNowDate());
        return sysBizOrderGoodsMapper.insert(sysBizOrderGoods);
    }

    /**
     * 修改订单商品
     *
     * @param sysBizOrderGoods 订单商品
     * @return 结果
     */
    @Override
    public int updateSysBizOrderGoods(SysBizOrderGoods sysBizOrderGoods) {
        sysBizOrderGoods.setUpdateTime(DateUtils.getNowDate());
        return sysBizOrderGoodsMapper.updateById(sysBizOrderGoods);
    }

    /**
     * 批量删除订单商品
     *
     * @param ids 需要删除的订单商品主键
     * @return 结果
     */
    @Override
    public int deleteSysBizOrderGoodsByIds(Long[] ids) {
        return sysBizOrderGoodsMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除订单商品信息
     *
     * @param id 订单商品主键
     * @return 结果
     */
    @Override
    public int deleteSysBizOrderGoodsById(Long id) {
        return sysBizOrderGoodsMapper.deleteById(id);
    }
}
